/******************************************************************
 * @version      : 1.0
 * @Author       : zhl
 * @Date         : 2023-05-04 18:03:33
 * @LastEditors  : zhl
 * @E-Mail       : zhll168@163.com
 * @Description  : 业务描述
 ******************************************************************/
#include "curl/curl.h"
#include "CThreadNotify.h"
#include "CMosquittoManager.h"
#include <iostream>
#include <memory>
#include <string>
#include <list>


class FileUpload
{
private:
    /* data */
    static FileUpload c_instance;
    uint8_t *c_buf;
    std::shared_ptr<CMosquittoManager> c_mm;
    

private:
    void init_thread();
    
public:
    CThreadNotify c_thread_notify;
    CThreadNotify c_upload_notify;
    std::list<int>   c_type;
    int  c_packet_num;
    uint64_t  c_req_id;
    int  c_packet_total;
    std::string c_filename;
    char c_sn[32];
public:
    FileUpload(/* args */);
    ~FileUpload();

    static FileUpload& getInstance();
    int compress_file(int type, std::string fname);
    void init(std::shared_ptr<CMosquittoManager> mm, char* sn);
    char* get_sn(char *sn, int len);
    size_t getFileSize(const char *fileName);
    std::string get_file_name(std::string &filename);

    static void upload_thread(FileUpload *pfup);
    int  upload_log_file(int type, uint64_t req_id);
    int  report_log(FILE *fp);
    FILE *get_log_file(int type);
    int  get_packate_total(std::string fname);
    int  get_packet(int packet_num, uint64_t req_id);
    void start_signal();
    void get_signal();
    std::string get_file_name_no_path(std::string fname);
};
